package com.pig4cloud.pigx.strategy.config.mq;

import com.pig4cloud.pigx.strategy.constant.StrategyMqConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 策略模块mq配置
 *
 * @since 2022/11/28 15:28
 */
@Configuration
public class StrategyMqConfig {

    /**
     * strategy.task.contract.handle
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyTaskContractHandleExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_TASK_CONTRACT_HANDLE);
    }

    /**
     * strategy.task.contract.handle
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyTaskContractHandleQueue() {
        return QueueBuilder.durable(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_TASK_CONTRACT_HANDLE)
                .ttl(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_TASK_CONTRACT_HANDLE_TTL)
                .build();
    }

    /**
     * strategy.task.contract.handle
     *
     * @param strategyTaskContractHandleExchange 交换机
     * @param strategyTaskContractHandleQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyTaskContractHandle(FanoutExchange strategyTaskContractHandleExchange, Queue strategyTaskContractHandleQueue) {
        return BindingBuilder.bind(strategyTaskContractHandleQueue)
                .to(strategyTaskContractHandleExchange);
    }

    /**
     * strategy.delay.order.contract.sync
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyDelayOrderContractSyncExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_DELAY_STRATEGY_ORDER_CONTRACT_SYNC);
    }

    /**
     * strategy.delay.order.contract.sync
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyDelayOrderContractSyncQueue() {
        return QueueBuilder.durable(StrategyMqConstant.QUEUE_FANOUT_DELAY_STRATEGY_ORDER_CONTRACT_SYNC)
                .ttl(StrategyMqConstant.QUEUE_FANOUT_DELAY_STRATEGY_ORDER_CONTRACT_SYNC_TTL)
                .deadLetterExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_ORDER_CONTRACT_SYNC)
                .deadLetterRoutingKey("")
                .build();
    }

    /**
     * strategy.delay.order.contract.sync
     *
     * @param strategyDelayOrderContractSyncExchange 交换机
     * @param strategyDelayOrderContractSyncQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyDelayOrderContractSync(FanoutExchange strategyDelayOrderContractSyncExchange, Queue strategyDelayOrderContractSyncQueue) {
        return BindingBuilder.bind(strategyDelayOrderContractSyncQueue)
                .to(strategyDelayOrderContractSyncExchange);
    }

    /**
     * strategy.order.contract.sync
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyOrderContractSyncExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_ORDER_CONTRACT_SYNC);
    }

    /**
     * strategy.order.contract.sync
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyOrderContractSyncQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_ORDER_CONTRACT_SYNC);
    }

    /**
     * strategy.order.contract.sync
     *
     * @param strategyOrderContractSyncExchange 交换机
     * @param strategyOrderContractSyncQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyOrderContractSync(FanoutExchange strategyOrderContractSyncExchange, Queue strategyOrderContractSyncQueue) {
        return BindingBuilder.bind(strategyOrderContractSyncQueue)
                .to(strategyOrderContractSyncExchange);
    }

    /**
     * strategy.contract.pause
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyContractPauseExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_CONTRACT_PAUSE);
    }

    /**
     * strategy.contract.pause
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyContractPauseQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_CONTRACT_PAUSE);
    }

    /**
     * strategy.contract.pause
     *
     * @param strategyContractPauseExchange 交换机
     * @param strategyContractPauseQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyContractPause(FanoutExchange strategyContractPauseExchange, Queue strategyContractPauseQueue) {
        return BindingBuilder.bind(strategyContractPauseQueue)
                .to(strategyContractPauseExchange);
    }

    /**
     * strategy.contract.restore
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyContractRestoreExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_CONTRACT_RESTORE);
    }

    /**
     * strategy.contract.restore
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyContractRestoreQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_CONTRACT_RESTORE);
    }

    /**
     * strategy.contract.restore
     *
     * @param strategyContractRestoreExchange 交换机
     * @param strategyContractRestoreQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyContractRestore(FanoutExchange strategyContractRestoreExchange, Queue strategyContractRestoreQueue) {
        return BindingBuilder.bind(strategyContractRestoreQueue)
                .to(strategyContractRestoreExchange);
    }

    /**
     * strategy.position.contract.close
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyPositionContractCloseExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_POSITION_CONTRACT_CLOSE);
    }

    /**
     * strategy.position.contract.close
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyPositionContractCloseQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_POSITION_CONTRACT_CLOSE);
    }

    /**
     * strategy.position.contract.close
     *
     * @param strategyPositionContractCloseExchange 交换机
     * @param strategyPositionContractCloseQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyPositionContractClose(FanoutExchange strategyPositionContractCloseExchange, Queue strategyPositionContractCloseQueue) {
        return BindingBuilder.bind(strategyPositionContractCloseQueue)
                .to(strategyPositionContractCloseExchange);
    }

    /**
     * strategy.contract.fuel.recharge
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyContractFuelRechargeExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_CONTRACT_FUEL_RECHARGE);
    }

    /**
     * strategy.contract.fuel.recharge
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyContractFuelRechargeQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_CONTRACT_FUEL_RECHARGE);
    }

    /**
     * strategy.contract.fuel.recharge
     *
     * @param strategyContractFuelRechargeExchange 交换机
     * @param strategyContractFuelRechargeQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyContractFuelRecharge(FanoutExchange strategyContractFuelRechargeExchange, Queue strategyContractFuelRechargeQueue) {
        return BindingBuilder.bind(strategyContractFuelRechargeQueue)
                .to(strategyContractFuelRechargeExchange);
    }

    /**
     * strategy.task.contract.create
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyTaskContractCreateExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_TASK_CONTRACT_CREATE);
    }

    /**
     * strategy.task.contract.create
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyTaskContractCreateQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_TASK_CONTRACT_CREATE);
    }

    /**
     * strategy.task.contract.create
     *
     * @param strategyTaskContractCreateExchange 交换机
     * @param strategyTaskContractCreateQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyTaskContractCreate(FanoutExchange strategyTaskContractCreateExchange, Queue strategyTaskContractCreateQueue) {
        return BindingBuilder.bind(strategyTaskContractCreateQueue)
                .to(strategyTaskContractCreateExchange);
    }

    /**
     * strategy.contract.email
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyContractEmailExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_EMAIL);
    }

    /**
     * strategy.contract.email
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyContractEmailQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_EMAIL);
    }

    /**
     * strategy.contract.email
     *
     * @param strategyContractEmailExchange 交换机
     * @param strategyContractEmailQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyContractEmail(FanoutExchange strategyContractEmailExchange, Queue strategyContractEmailQueue) {
        return BindingBuilder.bind(strategyContractEmailQueue)
                .to(strategyContractEmailExchange);
    }

    /**
     * strategy.contract.fuel.warning
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyContractFuelWarningExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_CONTRACT_FUEL_WARNING);
    }

    /**
     * strategy.contract.fuel.warning
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyContractFuelWarningQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_CONTRACT_FUEL_WARNING);
    }

    /**
     * strategy.contract.fuel.warning
     *
     * @param strategyContractFuelWarningExchange 交换机
     * @param strategyContractFuelWarningQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyContractFuelWarning(FanoutExchange strategyContractFuelWarningExchange, Queue strategyContractFuelWarningQueue) {
        return BindingBuilder.bind(strategyContractFuelWarningQueue)
                .to(strategyContractFuelWarningExchange);
    }

    /**
     * strategy.task.contract.error.settlement
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyTaskContractErrorSettlementExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_TASK_CONTRACT_ERROR_SETTLEMENT);
    }

    /**
     * strategy.task.contract.error.settlement
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyTaskContractErrorSettlementQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_TASK_CONTRACT_ERROR_SETTLEMENT);
    }

    /**
     * strategy.task.contract.error.settlement
     *
     * @param strategyTaskContractErrorSettlementExchange 交换机
     * @param strategyTaskContractErrorSettlementQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyTaskContractErrorSettlement(FanoutExchange strategyTaskContractErrorSettlementExchange, Queue strategyTaskContractErrorSettlementQueue) {
        return BindingBuilder.bind(strategyTaskContractErrorSettlementQueue)
                .to(strategyTaskContractErrorSettlementExchange);
    }


    /**
     * strategy.delay.stop.order.contract.sync
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyDelayStopOrderContractSyncExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_DELAY_STRATEGY_STOP_ORDER_CONTRACT_SYNC);
    }

    /**
     * strategy.delay.stop.order.contract.sync
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyDelayStopOrderContractSyncQueue() {
        return QueueBuilder.durable(StrategyMqConstant.QUEUE_FANOUT_DELAY_STRATEGY_STOP_ORDER_CONTRACT_SYNC)
                .ttl(StrategyMqConstant.QUEUE_FANOUT_DELAY_STRATEGY_STOP_ORDER_CONTRACT_SYNC_TTL)
                .deadLetterExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_STOP_ORDER_CONTRACT_SYNC)
                .deadLetterRoutingKey("")
                .build();
    }

    /**
     * strategy.delay.stop.order.contract.sync
     *
     * @param strategyDelayStopOrderContractSyncExchange 交换机
     * @param strategyDelayStopOrderContractSyncQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyDelayStopOrderContractSync(FanoutExchange strategyDelayStopOrderContractSyncExchange, Queue strategyDelayStopOrderContractSyncQueue) {
        return BindingBuilder.bind(strategyDelayStopOrderContractSyncQueue)
                .to(strategyDelayStopOrderContractSyncExchange);
    }

    /**
     * strategy.stop.order.contract.sync
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyStopOrderContractSyncExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_STOP_ORDER_CONTRACT_SYNC);
    }

    /**
     * strategy.stop.order.contract.sync
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyStopOrderContractSyncQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_STOP_ORDER_CONTRACT_SYNC);
    }

    /**
     * strategy.stop.order.contract.sync
     *
     * @param strategyStopOrderContractSyncExchange 交换机
     * @param strategyStopOrderContractSyncQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyStopOrderContractSync(FanoutExchange strategyStopOrderContractSyncExchange, Queue strategyStopOrderContractSyncQueue) {
        return BindingBuilder.bind(strategyStopOrderContractSyncQueue)
                .to(strategyStopOrderContractSyncExchange);
    }

    /**
     * strategy.stop.order.contract.create
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyStopOrderContractCreateExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_STOP_ORDER_CONTRACT_CREATE);
    }

    /**
     * strategy.stop.order.contract.create
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyStopOrderContractCreateQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_STOP_ORDER_CONTRACT_CREATE);
    }

    /**
     * strategy.stop.order.contract.create
     *
     * @param strategyStopOrderContractCreateExchange 交换机
     * @param strategyStopOrderContractCreateQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyStopOrderContractCreate(FanoutExchange strategyStopOrderContractCreateExchange, Queue strategyStopOrderContractCreateQueue) {
        return BindingBuilder.bind(strategyStopOrderContractCreateQueue)
                .to(strategyStopOrderContractCreateExchange);
    }

    /**
     * strategy.stop.order.contract.cancel
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyStopOrderContractCancelExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_STOP_ORDER_CONTRACT_CANCEL);
    }

    /**
     * strategy.stop.order.contract.cancel
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyStopOrderContractCancelQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_STOP_ORDER_CONTRACT_CANCEL);
    }

    /**
     * strategy.stop.order.contract.cancel
     *
     * @param strategyStopOrderContractCancelExchange 交换机
     * @param strategyStopOrderContractCancelQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyStopOrderContractCancel(FanoutExchange strategyStopOrderContractCancelExchange, Queue strategyStopOrderContractCancelQueue) {
        return BindingBuilder.bind(strategyStopOrderContractCancelQueue)
                .to(strategyStopOrderContractCancelExchange);
    }

    /**
     * strategy.position.contract.open.manual
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyPositionOpenManualExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_POSITION_CONTRACT_OPEN_MANUAL);
    }

    /**
     * strategy.position.contract.open.manual
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyPositionOpenManualQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_POSITION_CONTRACT_OPEN_MANUAL);
    }

    /**
     * strategy.position.contract.open.manual
     *
     * @param strategyPositionOpenManualExchange 交换机
     * @param strategyPositionOpenManualQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyPositionOpenManual(FanoutExchange strategyPositionOpenManualExchange, Queue strategyPositionOpenManualQueue) {
        return BindingBuilder.bind(strategyPositionOpenManualQueue)
                .to(strategyPositionOpenManualExchange);
    }

    /**
     * strategy.position.contract.close.part
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange strategyPositionClosePartExchange() {
        return new FanoutExchange(StrategyMqConstant.EXCHANGE_FANOUT_STRATEGY_POSITION_CONTRACT_CLOSE_PART);
    }

    /**
     * strategy.position.contract.close.part
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue strategyPositionClosePartQueue() {
        return new Queue(StrategyMqConstant.QUEUE_FANOUT_STRATEGY_POSITION_CONTRACT_CLOSE_PART);
    }

    /**
     * strategy.position.contract.close.part
     *
     * @param strategyPositionClosePartExchange 交换机
     * @param strategyPositionClosePartQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bindStrategyPositionClosePart(FanoutExchange strategyPositionClosePartExchange, Queue strategyPositionClosePartQueue) {
        return BindingBuilder.bind(strategyPositionClosePartQueue)
                .to(strategyPositionClosePartExchange);
    }
}
